import os

def merge_file(me_file, input_file_path) :
    # "D:\\test\\E1_V0"
    file1 = open(me_file, "r", encoding="utf-8")
    file2 = open(input_file_path, "r", encoding="utf-8")
    file_list1 = file1.read().splitlines()
    file_list2 = file2.read().splitlines()

    # print(len(file_list1))
    # # print(type(file1))

    file_list3 = []
    for i, n in enumerate(file_list1):
        s = ''
        if len(file_list2) >= i :
            s = str(n) + "," + str(file_list2[i]) + "\n"
        else:
            s = str(n) + "\n"
        file_list3.append(s)

    file3 = open(me_file, "w", encoding="utf-8")
    file3.writelines(file_list3)

    file1.close()
    file2.close()
    file3.close()

def get_allfile(path):
    all_file = []
    for f in os.listdir(path):
        f_name = os.path.join(path, f)
        all_file.append(f_name)
    return all_file

if __name__ == '__main__':
    dir = get_allfile("D:\\test\\")
    cnt = 0
    me_path = dir[0]
    print(dir)
    print(len(dir))
    for i in dir:
        if cnt == 0:
            cnt += 1
            continue
        merge_file(me_path, i)